package is.bean.entity.xdumper.session;

import java.util.Date;

/**
 *
 * @author aspr0
 */
public class XdumperSession
{
    private Integer id;
    private Action action;
    private String filePath;
    private Date timeStart;
    private Date timeEnd;

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getAction()
    {
        return action.toString();
    }

    public void setAction(String action)
    {
        if (action.equals(Action.EXPORT.toString()))
        {
            this.action = Action.EXPORT;
        }
        else if (action.equals(Action.IMPORT.toString()))
        {
            this.action = Action.IMPORT;
        }
        else
        {
            throw new RuntimeException("Wrong action!");
        }
    }

    public void setAction(Action action)
    {
        this.action = action;
    }

    public String getFilePath()
    {
        return filePath;
    }

    public void setFilePath(String filePath)
    {
        this.filePath = filePath;
    }

    public Date getTimeStart()
    {
        return timeStart;
    }

    public Long getTimeStartLong()
    {
        return (timeStart == null) ? null : timeStart.getTime();
    }

    public void setTimeStart(Long timeStart)
    {
        this.timeStart = new Date(timeStart);
    }

    public Date getTimeEnd()
    {
        return timeEnd;
    }

    public Long getTimeEndLong()
    {
        return (timeEnd == null) ? null : timeEnd.getTime();
    }

    public void setTimeEnd(Long timeEnd)
    {
        this.timeEnd = new Date(timeEnd);
    }
}
